Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional internal routing #8

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

aschmahmann
Copy link
Contributor

@aschmahmann aschmahmann commented Oct 6, 2023

Falls back to using the Amino DHT + cid.contact as an IPNI resolver if there is no routingV1 endpoint passed.

A few notes:

  • I may have overdone it on configurability here
    • It could be useful to test the configurations here and see what's most efficient/useful in practice
    • This shows some of the options we have so we can talk about which ones to keep/pull out
  • The reason to consider spinning up a separate libp2p host for DHT vs Bitswap work is basically to reduce noise from Bitswap while crawling the network. I'm not sure whether this will actually help, and ideally we wouldn't need this because Bitswap clients (mostly boxo/bitswap) would be better about how many requests they send to newly discovered non-local peers where there isn't external information that the peer is likely useful.
  • The reason to consider the accelerated client is basically because lookups (particularly IPNS ones) should get a bunch faster and realistically for high-traffic gateway nodes the routing table should (with a better DHT client implementation that caches more of the routing table) end up full pretty quickly anyhow given the Amino DHT has ~40k server nodes.
  • The combined client is basically a hack to deal with the fact the FullRT doesn't do the smarter thing of slowly building its routing table cache and being usable the whole time but is more of a binary "ready/not" so the standard client patches up the times when it's not ready.
  • I didn't bother using the KuboRPCURLs as routing proxies. Realistically the nodes being targeted with KuboRPCURLs should just be hit with RoutingV1 instead given that kubo v0.23.0 is out. While newer, it's something we've standardized and supports things like HTTP caching.
  • We can delete the "ProxyRouting" code that uses the KuboRPCURLs for routing. Might want to take the code there for configuring the HTTP RoundTripper used for RoutingV1 though.

cc @hsanjuan

} else {
// If there are no delegated routing endpoints run an accelerated Amino DHT client and send IPNI requests to cid.contact

// TODO: This datastore shouldn't end up containing anything anyway so this could potentially just be a null datastore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this... aren't dht records stored in this datastore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I thought that anything retrieved from the DHT would be stored locally too, even if you are only a client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can double check, but there's no reason to implement what is effectively record caching at this layer. That's not to say the code won't do that (I suspect at least for IPNS records it will) just that it's mostly non-sensical (e.g. IPNS records caching is better done at a layer that understands IPNS records like namesys)

Comment on lines +195 to +202
fullrt.DHTOption(
dht.Validator(record.NamespacedValidator{
"pk": record.PublicKeyValidator{},
"ipns": ipns.Validator{KeyBook: h.Peerstore()},
}),
dht.Datastore(memDS),
dht.BootstrapPeers(dht.GetDefaultBootstrapPeerAddrInfos()...),
dht.BucketSize(20),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the fullRT dht understand dht.ModeClient? This nodes shouldn't be storing records for other people even if they are publicly reachable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure it doesn't, but that's because it is only a client (i.e. it never operates in server mode)

Comment on lines +210 to +222
switch cfg.DHTType {
case Combined:
dhtRouter = &bundledDHT{
standard: standardClient,
fullRT: fullRTClient,
}
case Standard:
dhtRouter = standardClient
case Accelerated:
dhtRouter = fullRTClient
default:
return nil, fmt.Errorf("unsupported DHT type")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I regular DHT should just use combined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, feel free to rename however you want. Just wanted to illustrate the options for you and allow us to test them out if we want to evaluate the performance of them.

} else {
// If there are no delegated routing endpoints run an accelerated Amino DHT client and send IPNI requests to cid.contact

// TODO: This datastore shouldn't end up containing anything anyway so this could potentially just be a null datastore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I thought that anything retrieved from the DHT would be stored locally too, even if you are only a client.

@hsanjuan
Copy link
Contributor

hsanjuan commented Oct 6, 2023

I merge this and will finish on the original PR. Thanks!!

@hsanjuan hsanjuan merged commit 66626c5 into feat/deployment-basics Oct 6, 2023
8 of 9 checks passed
@hsanjuan hsanjuan deleted the feat/optional-internal-routing branch October 6, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants